package com.example.daniel.qrcodescan;

import android.content.res.Configuration;
import android.content.res.Resources;

import java.util.Locale;

public class LanguageHandler {
    public static void changeLocale(Resources res, String locale) {

        Configuration config;
        config = new Configuration(res.getConfiguration());

        switch (locale) {
            case "en":
                config.locale = Locale.ENGLISH;
                break;
            case "cn":
                config.locale = Locale.SIMPLIFIED_CHINESE;
                break;
            case "tw":
                config.locale = Locale.TRADITIONAL_CHINESE;
                break;
            default:
                config.locale = Locale.ENGLISH;
                break;
        }
        res.updateConfiguration(config, res.getDisplayMetrics());
        // reload files from assets directory
    }
}
